package org.sdp.pearproject.service.impl;


import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import org.sdp.pearproject.dto.request.*;
import org.sdp.pearproject.dto.response.*;
import org.sdp.pearproject.dao.domain.*;
import org.sdp.pearproject.service.*;
import org.sdp.pearproject.service.custom.*;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

/**
 * @ClassName: MemberAccountServiceImpl
 * @Description:
 * @Author: SDP
 * @Date: 2022-07-27
 * @Version: 1.0
 * Table: pear_member_account
 * Comment:
 * 组织账号表
 */
@Service
public class MemberAccountServiceImpl extends MemberAccountServiceCustomImpl implements MemberAccountService {

    static {
        beanClassNameMap.put("member_account", "memberAccountServiceImpl");
        listMethodNameMap.put("member_account", "listMemberAccount");
        listMethodParameterClassNameMap.put("member_account", "MemberAccountQueryRequest");
        updateMethodNameMap.put("member_account", "updateMemberAccount");
        updateMethodParameterClassNameMap.put("member_account", "MemberAccountUpdateRequest");
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer addMemberAccount(MemberAccountAddRequest request) throws Exception {
        super.fixRequest("member_account", "add", request);
        return super.addMemberAccount(request);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer updateMemberAccount(MemberAccountUpdateRequest request) throws Exception {
        MemberAccount record = null;
        record = memberAccountMapper.selectByPrimaryKey(request.getId());
        super.fixRequest("member_account", "update", request, record);
        return super.updateMemberAccount(request);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer deleteMemberAccount(MemberAccountDeleteRequest request) throws Exception {
        if (needCheckDeleteList(request)) {
            List<MemberAccount> list = null;
            MemberAccountExample example = new MemberAccountExample();
            example.createCriteria().andIdIn(request.getIdList());
            list = memberAccountMapper.selectByExample(example);
            fixRequest("member_account", "delete", request, list);
        } else {
            fixRequest("member_account", "delete", request);
        }
        return super.deleteMemberAccount(request);
    }

    @Override
    public MemberAccountQueryResponse queryMemberAccount(MemberAccountQueryRequest request) throws Exception {
        super.checkNonNull(request.getId(), "id");
        MemberAccountQueryResponse result = super.queryMemberAccount(request);
        checkResult("member_account", "query", request, result);
        return result;
    }

    @Override
    public List<MemberAccountQueryResponse> listMemberAccount(MemberAccountQueryRequest request) throws Exception {
        List<MemberAccountQueryResponse> list = super.listMemberAccount(request);
        checkResult("member_account", "list", request, list);
        return list;
    }

    @Override
    public Integer countMemberAccount(MemberAccountQueryRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("member_account", "count", request);
        return super.countMemberAccount(request);
    }

    @Override
    public BaseStatResponse statMemberAccount(MemberAccountQueryRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("member_account", "stat", request);
        return super.statMemberAccount(request);
    }

}
